<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - smart_ptr/detail/sp_counted_impl.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">smart_ptr/detail</a> - sp_counted_impl.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">8</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">75.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">6</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
<span class="lineNum">       2 </span>                : #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
<span class="lineNum">       3 </span>                : 
<span class="lineNum">       4 </span>                : // MS compatible compilers support #pragma once
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : #if defined(_MSC_VER) &amp;&amp; (_MSC_VER &gt;= 1020)
<span class="lineNum">       7 </span>                : # pragma once
<span class="lineNum">       8 </span>                : #endif
<span class="lineNum">       9 </span>                : 
<span class="lineNum">      10 </span>                : //
<span class="lineNum">      11 </span>                : //  detail/sp_counted_impl.hpp
<span class="lineNum">      12 </span>                : //
<span class="lineNum">      13 </span>                : //  Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
<span class="lineNum">      14 </span>                : //  Copyright 2004-2005 Peter Dimov
<span class="lineNum">      15 </span>                : //
<span class="lineNum">      16 </span>                : // Distributed under the Boost Software License, Version 1.0. (See
<span class="lineNum">      17 </span>                : // accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">      18 </span>                : // http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">      19 </span>                : //
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span>                : #include &lt;boost/config.hpp&gt;
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : #if defined(BOOST_SP_USE_STD_ALLOCATOR) &amp;&amp; defined(BOOST_SP_USE_QUICK_ALLOCATOR)
<span class="lineNum">      24 </span>                : # error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.
<span class="lineNum">      25 </span>                : #endif
<span class="lineNum">      26 </span>                : 
<span class="lineNum">      27 </span>                : #include &lt;boost/checked_delete.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/smart_ptr/detail/sp_counted_base.hpp&gt;
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : #if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
<span class="lineNum">      31 </span>                : #include &lt;boost/smart_ptr/detail/quick_allocator.hpp&gt;
<span class="lineNum">      32 </span>                : #endif
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span>                : #if defined(BOOST_SP_USE_STD_ALLOCATOR)
<span class="lineNum">      35 </span>                : #include &lt;memory&gt;           // std::allocator
<span class="lineNum">      36 </span>                : #endif
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span>                : #include &lt;cstddef&gt;          // std::size_t
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span>                : namespace boost
<span class="lineNum">      41 </span>                : {
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      44 </span>                : 
<span class="lineNum">      45 </span>                : void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn );
<span class="lineNum">      46 </span>                : void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn );
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : #endif
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span>                : namespace detail
<span class="lineNum">      51 </span>                : {
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                : template&lt;class X&gt; class sp_counted_impl_p: public sp_counted_base
<span class="lineNum">      54 </span><span class="lineCov">             66 : {</span>
<span class="lineNum">      55 </span>                : private:
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span>                :     X * px_;
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span>                :     sp_counted_impl_p( sp_counted_impl_p const &amp; );
<span class="lineNum">      60 </span>                :     sp_counted_impl_p &amp; operator= ( sp_counted_impl_p const &amp; );
<span class="lineNum">      61 </span>                : 
<span class="lineNum">      62 </span>                :     typedef sp_counted_impl_p&lt;X&gt; this_type;
<span class="lineNum">      63 </span>                : 
<span class="lineNum">      64 </span>                : public:
<span class="lineNum">      65 </span>                : 
<span class="lineNum">      66 </span><span class="lineCov">             68 :     explicit sp_counted_impl_p( X * px ): px_( px )</span>
<span class="lineNum">      67 </span>                :     {
<span class="lineNum">      68 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      69 </span>                :         boost::sp_scalar_constructor_hook( px, sizeof(X), this );
<span class="lineNum">      70 </span>                : #endif
<span class="lineNum">      71 </span><span class="lineCov">             68 :     }</span>
<span class="lineNum">      72 </span>                : 
<span class="lineNum">      73 </span><span class="lineCov">             66 :     virtual void dispose() // nothrow</span>
<span class="lineNum">      74 </span>                :     {
<span class="lineNum">      75 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      76 </span>                :         boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
<span class="lineNum">      77 </span>                : #endif
<span class="lineNum">      78 </span><span class="lineCov">             66 :         boost::checked_delete( px_ );</span>
<span class="lineNum">      79 </span><span class="lineCov">             66 :     }</span>
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span><span class="lineNoCov">              0 :     virtual void * get_deleter( detail::sp_typeinfo const &amp; )</span>
<span class="lineNum">      82 </span>                :     {
<span class="lineNum">      83 </span><span class="lineNoCov">              0 :         return 0;</span>
<span class="lineNum">      84 </span>                :     }
<span class="lineNum">      85 </span>                : 
<span class="lineNum">      86 </span>                : #if defined(BOOST_SP_USE_STD_ALLOCATOR)
<span class="lineNum">      87 </span>                : 
<span class="lineNum">      88 </span>                :     void * operator new( std::size_t )
<span class="lineNum">      89 </span>                :     {
<span class="lineNum">      90 </span>                :         return std::allocator&lt;this_type&gt;().allocate( 1, static_cast&lt;this_type *&gt;(0) );
<span class="lineNum">      91 </span>                :     }
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span>                :     void operator delete( void * p )
<span class="lineNum">      94 </span>                :     {
<span class="lineNum">      95 </span>                :         std::allocator&lt;this_type&gt;().deallocate( static_cast&lt;this_type *&gt;(p), 1 );
<span class="lineNum">      96 </span>                :     }
<span class="lineNum">      97 </span>                : 
<span class="lineNum">      98 </span>                : #endif
<span class="lineNum">      99 </span>                : 
<span class="lineNum">     100 </span>                : #if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
<span class="lineNum">     101 </span>                : 
<span class="lineNum">     102 </span>                :     void * operator new( std::size_t )
<span class="lineNum">     103 </span>                :     {
<span class="lineNum">     104 </span>                :         return quick_allocator&lt;this_type&gt;::alloc();
<span class="lineNum">     105 </span>                :     }
<span class="lineNum">     106 </span>                : 
<span class="lineNum">     107 </span>                :     void operator delete( void * p )
<span class="lineNum">     108 </span>                :     {
<span class="lineNum">     109 </span>                :         quick_allocator&lt;this_type&gt;::dealloc( p );
<span class="lineNum">     110 </span>                :     }
<span class="lineNum">     111 </span>                : 
<span class="lineNum">     112 </span>                : #endif
<span class="lineNum">     113 </span>                : };
<span class="lineNum">     114 </span>                : 
<span class="lineNum">     115 </span>                : //
<span class="lineNum">     116 </span>                : // Borland's Codeguard trips up over the -Vx- option here:
<span class="lineNum">     117 </span>                : //
<span class="lineNum">     118 </span>                : #ifdef __CODEGUARD__
<span class="lineNum">     119 </span>                : # pragma option push -Vx-
<span class="lineNum">     120 </span>                : #endif
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span>                : template&lt;class P, class D&gt; class sp_counted_impl_pd: public sp_counted_base
<span class="lineNum">     123 </span>                : {
<span class="lineNum">     124 </span>                : private:
<span class="lineNum">     125 </span>                : 
<span class="lineNum">     126 </span>                :     P ptr; // copy constructor must not throw
<span class="lineNum">     127 </span>                :     D del; // copy constructor must not throw
<span class="lineNum">     128 </span>                : 
<span class="lineNum">     129 </span>                :     sp_counted_impl_pd( sp_counted_impl_pd const &amp; );
<span class="lineNum">     130 </span>                :     sp_counted_impl_pd &amp; operator= ( sp_counted_impl_pd const &amp; );
<span class="lineNum">     131 </span>                : 
<span class="lineNum">     132 </span>                :     typedef sp_counted_impl_pd&lt;P, D&gt; this_type;
<span class="lineNum">     133 </span>                : 
<span class="lineNum">     134 </span>                : public:
<span class="lineNum">     135 </span>                : 
<span class="lineNum">     136 </span>                :     // pre: d(p) must not throw
<span class="lineNum">     137 </span>                : 
<span class="lineNum">     138 </span>                :     sp_counted_impl_pd( P p, D d ): ptr(p), del(d)
<span class="lineNum">     139 </span>                :     {
<span class="lineNum">     140 </span>                :     }
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                :     virtual void dispose() // nothrow
<span class="lineNum">     143 </span>                :     {
<span class="lineNum">     144 </span>                :         del( ptr );
<span class="lineNum">     145 </span>                :     }
<span class="lineNum">     146 </span>                : 
<span class="lineNum">     147 </span>                :     virtual void * get_deleter( detail::sp_typeinfo const &amp; ti )
<span class="lineNum">     148 </span>                :     {
<span class="lineNum">     149 </span>                :         return ti == BOOST_SP_TYPEID(D)? &amp;reinterpret_cast&lt;char&amp;&gt;( del ): 0;
<span class="lineNum">     150 </span>                :     }
<span class="lineNum">     151 </span>                : 
<span class="lineNum">     152 </span>                : #if defined(BOOST_SP_USE_STD_ALLOCATOR)
<span class="lineNum">     153 </span>                : 
<span class="lineNum">     154 </span>                :     void * operator new( std::size_t )
<span class="lineNum">     155 </span>                :     {
<span class="lineNum">     156 </span>                :         return std::allocator&lt;this_type&gt;().allocate( 1, static_cast&lt;this_type *&gt;(0) );
<span class="lineNum">     157 </span>                :     }
<span class="lineNum">     158 </span>                : 
<span class="lineNum">     159 </span>                :     void operator delete( void * p )
<span class="lineNum">     160 </span>                :     {
<span class="lineNum">     161 </span>                :         std::allocator&lt;this_type&gt;().deallocate( static_cast&lt;this_type *&gt;(p), 1 );
<span class="lineNum">     162 </span>                :     }
<span class="lineNum">     163 </span>                : 
<span class="lineNum">     164 </span>                : #endif
<span class="lineNum">     165 </span>                : 
<span class="lineNum">     166 </span>                : #if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                :     void * operator new( std::size_t )
<span class="lineNum">     169 </span>                :     {
<span class="lineNum">     170 </span>                :         return quick_allocator&lt;this_type&gt;::alloc();
<span class="lineNum">     171 </span>                :     }
<span class="lineNum">     172 </span>                : 
<span class="lineNum">     173 </span>                :     void operator delete( void * p )
<span class="lineNum">     174 </span>                :     {
<span class="lineNum">     175 </span>                :         quick_allocator&lt;this_type&gt;::dealloc( p );
<span class="lineNum">     176 </span>                :     }
<span class="lineNum">     177 </span>                : 
<span class="lineNum">     178 </span>                : #endif
<span class="lineNum">     179 </span>                : };
<span class="lineNum">     180 </span>                : 
<span class="lineNum">     181 </span>                : template&lt;class P, class D, class A&gt; class sp_counted_impl_pda: public sp_counted_base
<span class="lineNum">     182 </span>                : {
<span class="lineNum">     183 </span>                : private:
<span class="lineNum">     184 </span>                : 
<span class="lineNum">     185 </span>                :     P p_; // copy constructor must not throw
<span class="lineNum">     186 </span>                :     D d_; // copy constructor must not throw
<span class="lineNum">     187 </span>                :     A a_; // copy constructor must not throw
<span class="lineNum">     188 </span>                : 
<span class="lineNum">     189 </span>                :     sp_counted_impl_pda( sp_counted_impl_pda const &amp; );
<span class="lineNum">     190 </span>                :     sp_counted_impl_pda &amp; operator= ( sp_counted_impl_pda const &amp; );
<span class="lineNum">     191 </span>                : 
<span class="lineNum">     192 </span>                :     typedef sp_counted_impl_pda&lt;P, D, A&gt; this_type;
<span class="lineNum">     193 </span>                : 
<span class="lineNum">     194 </span>                : public:
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                :     // pre: d( p ) must not throw
<span class="lineNum">     197 </span>                : 
<span class="lineNum">     198 </span>                :     sp_counted_impl_pda( P p, D d, A a ): p_( p ), d_( d ), a_( a )
<span class="lineNum">     199 </span>                :     {
<span class="lineNum">     200 </span>                :     }
<span class="lineNum">     201 </span>                : 
<span class="lineNum">     202 </span>                :     virtual void dispose() // nothrow
<span class="lineNum">     203 </span>                :     {
<span class="lineNum">     204 </span>                :         d_( p_ );
<span class="lineNum">     205 </span>                :     }
<span class="lineNum">     206 </span>                : 
<span class="lineNum">     207 </span>                :     virtual void destroy() // nothrow
<span class="lineNum">     208 </span>                :     {
<span class="lineNum">     209 </span>                :         typedef typename A::template rebind&lt; this_type &gt;::other A2;
<span class="lineNum">     210 </span>                : 
<span class="lineNum">     211 </span>                :         A2 a2( a_ );
<span class="lineNum">     212 </span>                : 
<span class="lineNum">     213 </span>                :         this-&gt;~this_type();
<span class="lineNum">     214 </span>                :         a2.deallocate( this, 1 );
<span class="lineNum">     215 </span>                :     }
<span class="lineNum">     216 </span>                : 
<span class="lineNum">     217 </span>                :     virtual void * get_deleter( detail::sp_typeinfo const &amp; ti )
<span class="lineNum">     218 </span>                :     {
<span class="lineNum">     219 </span>                :         return ti == BOOST_SP_TYPEID( D )? &amp;reinterpret_cast&lt;char&amp;&gt;( d_ ): 0;
<span class="lineNum">     220 </span>                :     }
<span class="lineNum">     221 </span>                : };
<span class="lineNum">     222 </span>                : 
<span class="lineNum">     223 </span>                : #ifdef __CODEGUARD__
<span class="lineNum">     224 </span>                : # pragma option pop
<span class="lineNum">     225 </span>                : #endif
<span class="lineNum">     226 </span>                : 
<span class="lineNum">     227 </span>                : } // namespace detail
<span class="lineNum">     228 </span>                : 
<span class="lineNum">     229 </span>                : } // namespace boost
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span>                : #endif  // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
